#include "hemispherical_grid.h"

namespace Sirat {

namespace Common {
		
Hemispherical_Grid::Hemispherical_Grid(const unsigned short _width,const unsigned short _height,const Math::Vector& _position,const Math::Vector& _x,const Math::Vector& _y,const Math::Vector& _z) : Grid(_width,_height,_position,_x,_y,_z) { }

Hemispherical_Grid::Hemispherical_Grid() { }

Hemispherical_Grid::Hemispherical_Grid(const Hemispherical_Grid& _hemispherical_grid) : Grid(_hemispherical_grid) { }

Hemispherical_Grid::~Hemispherical_Grid() { }

Math::Vector Hemispherical_Grid::projection_transformation(unsigned int _pixel_x,unsigned int _pixel_y) {
	const double px = (2.0/width)*_pixel_x-1.0;
	const double py = (2.0/height)*_pixel_y-1.0;
	
	const double cos_teta1 = cos((M_PI/4.0)*px);
	const double cos_teta2 = cos((M_PI/4.0)*py);
	
	const double sin_teta1 = sin((M_PI/4.0)*px);
	const double sin_teta2 = sin((M_PI/4.0)*py);
	
	Math::Vector projection = x*cos_teta2*sin_teta1 + y*sin_teta2 + z*cos_teta2*cos_teta1;
	return projection;
}

Grid* Hemispherical_Grid::clone() {
	return new Hemispherical_Grid(*this);
}

Hemispherical_Grid& Hemispherical_Grid::operator=(const Hemispherical_Grid& _hemispherical_grid) {
	Grid::operator=(_hemispherical_grid);
	return *this;
}

}

}
